home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Oper (RU).ifs < prev    next >
Text File  |  2005-04-09  |  8KB  |  219 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=LA (Andrey Lukyanov)       (<link>l_a@hotmail.ru</link>)
  8. Title=Oper (Goblin)
  9. Description=Imports Goblin's movies info from oper.ru
  10. Site=http://www.oper.ru
  11. Language=RU
  12. Version=1.0 (09.04.2005)
  13. Requires=3.5.0
  14. Comments=╚∞∩ε≡≥Φ≡≤σ≥ Φφ⌠ε≡∞α÷Φ■ (ε≡ΦπΦφαδⁿφεσ φατΓαφΦσ, ∩σ≡σΓσΣσφφεσ πεßδΦφεΓ±Ωεσ φατΓαφΦσ Φ ε∩Φ±αφΦσ) ε ⌠Φδⁿ∞σ Γ πεßδΦφ±Ωε∞ ∩σ≡σΓεΣσ ± ε⌠Φ÷Φαδⁿφεπε ±αΘ≥α Goblin'a.
  15. License=This script is free; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version.
  16. GetInfo=1
  17.  
  18. [Options]
  19. TrTitle_AddWordGoblin=0|1|1=─εßαΓδ ≥ⁿ '(Goblin)' Γ Ωεφ÷σ ∩σ≡σΓσΣσφφεπε φατΓαφΦ |0=═σ ΣεßαΓδ ≥ⁿ '(Goblin)' Γ Ωεφ÷σ ∩σ≡σΓσΣσφφεπε φατΓαφΦ 
  20. OrTitle_AddWordGoblin=0|1|1=─εßαΓδ ≥ⁿ '(Goblin)' Γ Ωεφ÷σ ε≡ΦπΦφαδⁿφεπε φατΓαφΦ |0=═σ ΣεßαΓδ ≥ⁿ '(Goblin)' Γ Ωεφ÷σ ε≡ΦπΦφαδⁿφεπε φατΓαφΦ 
  21. Language_Goblin=0|1|1=╟α∩Φ±√Γα≥ⁿ Γ ∩εδσ ▀τ√Ω τφα≈σφΦσ 'Goblin'|0=═σ τα∩Φ±√Γα≥ⁿ Γ ∩εδσ ▀τ√Ω τφα≈σφΦσ 'Goblin'
  22.  
  23. ***************************************************)
  24.  
  25. program Oper;
  26. const
  27.   BaseAddress = 'http://www.oper.ru';
  28.   STR_WIN = '└α┴ß┬Γ├π─Σ┼σ╞µ╟τ╚Φ╔Θ╩Ω╦δ╠∞═φ╬ε╧∩╨≡╤±╥≥╙≤╘⌠╒⌡╓÷╫≈╪°┘∙┌·█√▄ⁿ▌²▐■▀ ';
  29.   STR_KOI = '■▐α└ß┴÷╓Σ─σ┼⌠╘π├⌡╒Φ╚Θ╔Ω╩δ╦∞╠φ═ε╬∩╧ ▀≡╨±╤≥╥≤╙µ╞Γ┬ⁿ▄√█τ╟°╪²▌∙┘≈╫·┌';
  30.  
  31. var
  32.   MovieName: string;
  33.   PagesAddresses: Array of String;
  34.   PagesTitles: Array of String;
  35.  
  36. function ParseURL(Text:String):String;
  37. var
  38.   BeginPos : Integer;
  39.   EndPos : Integer;
  40.   Value : String;
  41. begin
  42.  
  43.   repeat
  44.     BeginPos := Pos('<b>',Text);
  45.     If BeginPos > 0 Then
  46.     Begin
  47.       EndPos := Pos('</b>',Text);
  48.       Value := copy(Text, BeginPos, EndPos - BeginPos);
  49.       Value := StringReplace(Value,'<BR>',', ');
  50.       Value := StringReplace(Value,'<br>',', ');
  51.       HTMLRemoveTags(Value);
  52.       Delete(Text,1,EndPos);
  53.       If Length(result)>0 Then
  54.         result := result + ', ' + Value
  55.       else
  56.         result := Value;
  57.     end;
  58.   until BeginPos < 1;
  59.  
  60. end;
  61.  
  62. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  63. var
  64.   i: Integer;
  65. begin
  66.   result := -1;
  67.   if StartAt < 0 then
  68.     StartAt := 0;
  69.   for i := StartAt to List.Count-1 do
  70.     if Pos(AnsiLowerCase(Pattern), AnsiLowerCase(List.GetString(i))) <> 0 then
  71.     begin
  72.       result := i;
  73.       Break;
  74.     end;
  75. end;
  76.  
  77. // ∩≡ε÷σΣ≤≡α Φτ ±Ω≡Φ∩≥α Animator (RU)
  78. function KOIToWin(Source: string): string;
  79. var
  80.   i: integer;
  81.   s: string;
  82.   c: char;
  83.   chars: array of char;
  84. begin
  85.   Result := '';
  86.   SetArrayLength(chars, 256);
  87.   for i := 0 to 255 do
  88.     chars[i] := chr(i);
  89.   for i := 1 to length(STR_WIN) do
  90.     chars[ord(copy(STR_WIN, i, 1))] := copy(STR_KOI, i, 1);
  91.   for i := 1 to Length(Source) do
  92.     Result := Result + chars[ord(copy(Source, i, 1))];
  93.   Result := StringReplace(Result,'ú','╕'); // Φ±∩≡αΓδ σ≥ ε°ΦßΩ≤ ± ß≤ΩΓεΘ ╕
  94. end;
  95.  
  96. procedure AnalyzePage;
  97. var
  98.   ID, FilmName, Line, Address: String;
  99.   Page: TStringList;
  100.   FilmPage: TStringList;
  101.   BeginPos, EndPos, LineBeginPos, LineEndPos: Integer;
  102.   LinkI: Byte;
  103. begin
  104.   PickTreeClear; // ╬≈Φ±≥Ωα Σσ≡σΓα ⌠Φδⁿ∞εΓ
  105.   Page := TStringList.Create;
  106.   PickTreeAdd('╧εΦ±Ω ⌠Φδⁿ∞α: ' + MovieName, '');
  107.  
  108.   for LinkI := 0 to GetArrayLength(PagesAddresses)-1 do
  109.   begin
  110.       Address := BaseAddress+PagesAddresses[LinkI];
  111.       Page.Text := KOIToWin(GetPage(Address));
  112.       // Page.SaveToFile('c:\page'+IntToStr(LinkI)+'.txt'); // Σδ  ε≥δαΣΩΦ
  113.       // Page.LoadFromFile('c:\page'+IntToStr(LinkI)+'.txt');
  114.       PickTreeAdd(PagesTitles[LinkI], '');
  115.       LineBeginPos := FindLine('╤∩Φ±εΩ ∩σ≡σΓεΣεΓ:', Page, 10); // φα⌡εΣΦ∞ φα≈αδε ±∩Φ±Ωα ∩σ≡σΓεΣεΓ
  116.       LineEndPos := FindLine('<b>═εΓΦφΩΦ:</b><br><br>', Page, 10); // Σαδσσ ²≥εΘ δΦφΦΦ ⌠Φδⁿ∞α φσ ∞εµσ≥ ß√≥ⁿ
  117.       repeat
  118.       LineBeginPos := FindLine(MovieName, Page, LineBeginPos+1); // Σαδσσ c ²≥εΘ ∩ετΦ÷ΦΦ Φ∙σ∞ ⌠Φδⁿ∞
  119.       if (LineBeginPos > 0) and (LineBeginPos < LineEndPos) then // ⌠Φδⁿ∞ φαΘΣσφ
  120.         begin
  121.               Line:= Page.GetString(LineBeginPos); // ╧εδ≤≈ασ∞ ±≥≡εΩ≤ ± ⌠Φδⁿ∞ε∞
  122.               BeginPos := Pos('<a href=',Line)+8;
  123.               EndPos := Pos('>',Line);
  124.               ID := BaseAddress+copy(Line, BeginPos, EndPos - BeginPos); // ╧εδ≤≈ασ∞ αΣ≡σ± ±≥≡αφΦ÷√
  125.  
  126.               BeginPos := Pos('>',Line)+1;
  127.               EndPos := Pos('<hr ',Line);
  128.               FilmName := Copy(Line, BeginPos, EndPos - BeginPos); // ╧εδ≤≈ασ∞ φατΓαφΦσ Σδ  Γ√ßε≡α
  129.               FilmName := StringReplace(FilmName,'</a><br>',' (')+')';
  130.               PickTreeAdd(FilmName, ID);
  131.         end;
  132.       until (LineBeginPos = -1) or (LineBeginPos > LineEndPos);
  133.   end;
  134.   // PickTreeMoreLink('http://www.yandex.ru/yandsearch?ras=1&date=&text='+MovieName+'&spcctx=notfar&zone=all&linkto=&wordforms=all&lang=all&within=0&from_day=&from_month=&from_year=&to_day=9&to_month=4&to_year=2005&mime=all&Link=&numdoc=10&site=www.oper.ru&ds=');
  135.   If  PickTreeExec(Address) Then
  136.       AnalyzeMoviePage(Address); // ╧≡εαφαδΦτΦ≡εΓα≥ⁿ ±≥≡αφΦ÷≤ ± ⌠Φδⁿ∞ε∞
  137. end;
  138.  
  139. procedure AnalyzeMoviePage(Address: String);
  140. var
  141.   Page: TStringList;
  142.   LineNr : Integer;
  143.   Line, Value, TmpStr : String;
  144.   BeginPos, EndPos : Integer;
  145.  
  146. begin
  147.   Page := TStringList.Create;
  148.   Page.Text := KOIToWin(GetPage(Address));
  149.   // Page.SaveToFile('c:\movie.txt'); // Σδ  ε≥δαΣΩΦ
  150.   // Page.LoadFromFile('c:\movie.txt');
  151.  
  152.   // URL
  153.   SetField(fieldURL,Address);
  154.  
  155.   TmpStr := '<font size=2 class=verdana color=white><h1>';
  156.   LineNr := FindLine(TmpStr, Page, 0);
  157.   if LineNr > -1 then
  158.   begin
  159.     // Translated Title
  160.     Line := Page.GetString(LineNr);
  161.     Delete(Line,1, Pos(TmpStr,Line) + Length(TmpStr) - 1);
  162.     EndPos := pos('</h1>', Line) - 1;
  163.     Value := copy(Line, 1, EndPos);
  164.     Value := Trim(Value);
  165.     if GetOption('TrTitle_AddWordGoblin') = 1 then Value := Value + ' (Goblin)';
  166.     SetField(fieldTranslatedTitle, Value);
  167.  
  168.     // Original Title
  169.     Delete(Line,1,EndPos+5);
  170.     BeginPos:=pos('<h1>', Line)+4;
  171.     EndPos := pos('</h1>', Line)-1;
  172.     Value := copy(Line, BeginPos, EndPos - BeginPos + 1);
  173.     Value := Trim(Value);
  174.     if GetOption('OrTitle_AddWordGoblin') = 1 then Value := Value + ' (Goblin)';
  175.     SetField(fieldOriginalTitle, Value);
  176.   end;
  177.  
  178.   // Description
  179.   TmpStr := '<tr><td style="padding:20px" bgcolor=#252525><font size=2 class=verdana>';
  180.   LineNr := FindLine(TmpStr, Page, 1); // ═α≈αδε ±≥≡εΩΦ ε∩Φ±αφΦ 
  181.   if LineNr > -1 then
  182.   begin
  183.     Value := '';
  184.     Line := Page.GetString(LineNr);
  185.     repeat
  186.       Value := Value + Line;
  187.       LineNr := LineNr + 1;
  188.       Line := Page.GetString(LineNr);
  189.     until (Pos('╨σΩε∞σφΣ≤σ≥±  Ω ∩≡ε±∞ε≥≡≤ ', Line)>0) or (Pos('<br><br>» ', Line)>0) or (Pos('</table>', Line)>0);
  190.     Value := StringReplace(Value, '<br><br>', #13#10);
  191.     Value := StringReplace(Value, '<BR><BR>', #13#10);
  192.     Value := StringReplace(Value, '<br>', #13#10);
  193.     Value := StringReplace(Value, '<BR>', #13#10);
  194.     HTMLRemoveTags(Value);
  195.     Value := Trim(Value);
  196.     SetField(fieldDescription,Value);
  197.   end;
  198.  
  199.   // Language
  200.   if GetOption('Language_Goblin') = 1 then
  201.     SetField(fieldLanguages,'Goblin');
  202.  
  203. end;
  204.  
  205. begin
  206.     SetArrayLength(PagesAddresses, 2);
  207.     SetArrayLength(PagesTitles, 2);
  208.     PagesAddresses[0] := '/trans/?d=1';
  209.     PagesAddresses[1] := '/trans/?d=2';
  210.     PagesTitles[0] := '╤≥≤ΣΦ  ∩εδφ√Θ ╧²';
  211.     PagesTitles[1] := '╤≥≤ΣΦ  ┴εµⁿ  ╚±Ω≡α';
  212.  
  213.     MovieName := GetField(fieldOriginalTitle);
  214.     if MovieName = '' then
  215.       MovieName := GetField(fieldTranslatedTitle);
  216.     if Input('Import from oper.ru', 'Enter the title of the movie:', MovieName) then
  217.       AnalyzePage;
  218. end.
  219.